package com.dhl.fin.api.domain;

import com.dhl.fin.api.common.domain.BasicDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.List;

/**
 * @author becui
 * @date 4/1/2020
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "t_dictionary")

public class Dictionary extends BasicDomain {

    public Dictionary() {
    }

    public Dictionary(Long id, String name, String code, Dictionary parent, Project project) {
        this.id = id;
        this.name = name;
        this.code = code;
        this.parent = parent;
        this.project = project;
    }


    @Column(columnDefinition = "varchar(50)")
    private String name;

    @Column(columnDefinition = "varchar(50)")
    private String code;

    @ManyToOne
    @JoinColumn(name = "parent_id")
    private Dictionary parent;


    @ManyToOne
    @JoinColumn(name = "project_id")
    private Project project;


    @OneToMany(mappedBy = "parent")
    private List<Dictionary> children;

}
